      SUBROUTINE QUIKVIS5A2A(ITARG,IDTARG)
      IMPLICIT REAL*8 (A-H,O-Z)
C
C THIS ROUTINE IS PART OF THE QUIKVIS PROGRAM.  IT DOES ERROR CHECKS ON
C THE SCRATCH FILE TO BE SURE THE DATA THAT WAS WRITTEN AGREES WITH
C WHAT WE EXPECT TO FIND ON THE FILE. IF AN ERROR IS FOUND, THEN A
C CODING ERROR IS PRESENT. WE STOP HERE TO FORCE A CLOSER LOOK AT THE
C ERROR. THIS CODE IS PRESENT BECAUSE FUTURE PROGRAM MODS MAY INTRODUCE
C AN ERROR NOT SENSED OTHERWISE.
C
C
C VARIABLE      DIM       TYPE I/O DESCRIPTION
C --------      ---       ---- --- -----------
C
C ITARG          1         I*4  I  INDEX NUMBER IN IDTARG WHERE THE
C                                  CURRENT TARGET'S ID IS LOCATED.
C
C IDTARG      MAXTARGS     I*4  I  DESCRIBED IN QUIKVIS(=MAIN) PROLOGUE.
C
C***********************************************************************
C
C BY C PETRUZZO/GFSC/742.   2/86.
C       MODIFIED.... 9/86. CJP. REPLACED DIRECT READING OF SCRATCH FILE
C                               WITH CALL TO QV5READ.  COMMENT MODS.
C
C***********************************************************************
C
      INCLUDE 'QUIKVIS.INC'
C
      INTEGER*4 IDTARG(MAXTARGS)
      CHARACTER*16 CH16NAME
C
      IBUG = 0
      LUBUG = 19
C
C
C
      DO ITIME=1,NUMTIMES
C
C READ THE FILE
C
        CALL QV5READ(ITIME,
     *       T50,KDUM,ID,CH16NAME,
     *       FIRSTNODE,DELNODE,FIRSTMST,DELMST,NUMNODES,
     *       .FALSE.,DUM, .FALSE.,DUM, .FALSE.,DUM)
C
C VERIFY THAT TIME VALUE IS AS EXPECTED.
C
        TEST = TSTART + (ITIME-1)*DELTIME
        IF(DABS(T50-TEST).GT.1.D0) THEN
          STOP ' QUIKVIS5A2A. ERROR END 1. SEE CODE.'
          END IF
C
C
C VERIFY NODE OR MEAN SOLAR TIME PARAMETERS ARE AS EXPECTED.
C
        IF(NODEOPT.EQ.1) THEN
C
C        VERIFY CORRECT FIRST NODE AND NODE INCREMENT. IN QUIKVIS5A,
C        FIRSTNODE IS SET DIRECTLY FROM RAAN1, TO THE ERROR TOLERANCE
C        ON THIS CHECK IS TIGHT.
          TEMP = EQVANG( FIRSTNODE-RAAN1 )
          IF(TEMP.GT.PI) TEMP = DABS(TEMP - TWOPI)
          IF(TEMP.GT.1.D-8)
     *          STOP ' QUIKVIS5A2A. ERROR END 2. SEE CODE.'
          IF(DABS(DELNODE-DELRAAN).GT.1.D-8)
     *          STOP ' QUIKVIS5A2A. ERROR END 3. SEE CODE.'
          IF(NUMNODES.NE.NUMRAAN)
     *          STOP ' QUIKVIS5A2A. ERROR END 4. SEE CODE.'
C
        ELSE IF(NODEOPT.EQ.2) THEN
C
C        VERIFY CORRECT FIRST MEAN SOLAR TIME AND INCREMENT. IN
C        QUIKVIS5A, FIRSTMST IS COMPUTED VIA THE TIMLOC FUNCTION AND
C        MAY DIFFER SLIGHTLY FROM SOLTIM1. WE ARE LOOKING FOR GROSS
C        CODING ERRORS HERE, SO THE TOLERANCES ARE LOOSE.
          TEMP = DABS( FIRSTMST - SOLTIM1 )
          IF(TEMP.GT.43200.D0) TEMP = DABS(TEMP - 86400.D0)
          IF(TEMP.GT.10.D0)
     *          STOP ' QUIKVIS5A2A. ERROR END 5. SEE CODE.'
          IF(DABS(DELNODE/TWOPI*86400.D0-DELSOLT).GT.1.D0)
     *          STOP ' QUIKVIS5A2A. ERROR END 6. SEE CODE.'
          IF(NUMNODES.NE.NUMSOLT)
     *          STOP ' QUIKVIS5A2A. ERROR END 7. SEE CODE.'
C
        ELSE
C
C          BAD NODEOPT VALUE HAS CREPT IN
          STOP ' QUIKVIS5A2A. ERROR END 8. SEE CODE.'
          END IF
C
C VERIFY THAT THE TARGET ID IS AS EXPECTED.
C
        IF(ID.NE.IDTARG(ITARG))
     *    STOP ' QUIKVIS5A2A. ERROR END 9. SEE CODE.'
C
C
        END DO  ! END ITIME LOOP
C
      RETURN
C
C***********************************************************************
C
C
C**** INITIALIZATION CALL. PUT GLOBAL PARAMETER VALUES INTO THIS
C     ROUTINE'S LOCAL VARIABLES.
C
      ENTRY QVINIT5A2A
C
      CALL QUIKVIS999(-1,R8DATA,I4DATA,L4DATA)
      RETURN
C
C***********************************************************************
C
      END
